﻿using Xtensive.Orm;

namespace NoIndexOnReferenceFields.Model
{
    /*
     * By default, DataObjects.Net automatically adds index on every reference field to speed up query execution
     * that involves filtering by reference fields, e.g.
     * session.Query.All<Person>().Where(a => a.Father == somePerson)
     * 
     * In case your database doesn't really need index on a particular reference field, use [Field(Indexed = false)] construct
     */
    [HierarchyRoot]
    public class Person : Entity
    {
        [Field, Key]
        public int Id { get; private set; }

        [Field]
        public string Name { get; set; }

        [Field(Indexed = false)]
        public Person Father { get; set; }

        [Field(Indexed = false)]
        public Person Mother { get; set; }

        public Person(Session session) :
            base(session)
        {}
    }
}